__author__ = 'st316'
'''
Given numRows, generate the first numRows of Pascal's triangle.

For example, given numRows = 5,
Return

[
     [1],
    [1,1],
   [1,2,1],
  [1,3,3,1],
 [1,4,6,4,1]
]
'''


class Solution:
    # @return a list of lists of integers
    def generate(self, numRows):
        result = []
        if numRows == 0:
            return result
        for i in xrange(numRows):
            result.append([])
            for j in xrange(i + 1):
                if i > 0 and 0 < j < i:
                    result[i].append(result[i - 1][j - 1] + result[i - 1][j])
                else:
                    result[i].append(1)
        return result


if __name__ == '__main__':
    s = Solution()
    print s.generate(5)